package com.zhcd.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zhcd.sys.pojo.Doctor;
import com.zhcd.sys.mapper.DoctorMapper;
import com.zhcd.sys.pojo.Mattess;
import com.zhcd.sys.service.DoctorService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author feifei
 * @since 2021-11-29
 */
@Service
public class DoctorServiceImpl extends ServiceImpl<DoctorMapper, Doctor> implements DoctorService {
    @Autowired
    private DoctorMapper doctorMapper;

    //查询全部医生
    @Override
    public List<Doctor> getAll_Doctor() {
        return doctorMapper.selectList(null);
    }

    //按条件(电话、姓名、科室)查询医生
    @Override
    public List<Doctor> getList_Doctor(String doctorphone, String doctorname, String departmentname) {
        QueryWrapper<Doctor> objectQueryWrapper = new QueryWrapper<>();
        objectQueryWrapper.eq("DoctorPhone",doctorphone).or().eq("DoctorName",doctorname).or()
                .eq("DepartmentName",departmentname);
        return doctorMapper.selectList(objectQueryWrapper);
    }

    //查询单个医生
    @Override
    public Doctor getOne_Doctor(int doctorid) {
        return doctorMapper.selectById(doctorid);
    }

    //删除医生
    @Override
    public int del_Doctor(int doctorid) {
        return doctorMapper.deleteById(doctorid);
    }

    //修改医生
    @Override
    public int upd_Doctor(Doctor doctor) {
        return doctorMapper.updateById(doctor);
    }


    @Autowired
    private DoctorMapper DoctorMapper;

    @Override
    public List<Doctor> selectAll() {
        return DoctorMapper.selectList(null);
    }

    @Override
    public Doctor simpleObj(String id) {
        return DoctorMapper.selectById(id);
    }
    @Override
    public int Add(Doctor model) {
        return DoctorMapper.insert(model);
    }

    @Override
    public int Update(Doctor model) {
        return DoctorMapper.updateById(model);
    }

    @Override
    public int Delete(String id) {
        return DoctorMapper.deleteById(id);
    }
}
